/**
  ******************************************************************************
  * @file    operation_interface.c
  * @brief   运营平台接口处理
  ******************************************************************************
  */

#include "operation_interface.h"

typedef struct
{
    int32_t service_id;   /* 服务消息类型 */
    void    *callback;    /* 函数指针 */
} ops_service_map_t;

static ops_service_map_t g_ops_service_map[OPS_SERVICE_MAX_SIZE] =
{
    {OPS_ACTIVE_SERVICE_START_CHARGING_APP,    NULL},   /* APP启动充电 */
    {OPS_ACTIVE_SERVICE_STOP_CHARGING_APP,     NULL},   /* APP停止充电 */
    {OPS_ACTIVE_SERVICE_CARD_SYN,              NULL},   /* 离线卡数据同步 */
    {OPS_ACTIVE_SERVICE_CARD_CLEAR,            NULL},   /* 离线卡数据清除 */
    {OPS_ACTIVE_SERVICE_CARD_QUERY,            NULL},   /* 离线卡数据查询 */
    {OPS_ACTICE_SERVICE_FEE_STRATEGY,          NULL},   /* 计费策略 */
    {OPS_ACTIVE_SERVICE_TIME_SYN,              NULL},   /* 时间同步 */
    {OPS_ACTIVE_SERVICE_REBOOT,                NULL},   /* 重启 */
    {OPS_ACTIVE_SERVICE_START_UPDATE,          NULL},   /* 启动远程升级 */

    {OPS_PASSIVE_SERVICE_SIGN_IN,              NULL},   /* 登录签到（充电桩接入认证） */
    {OPS_PASSIVE_SERVICE_FEE_CHECK,            NULL},   /* 登录签到（充电桩接入认证） */
    {OPS_PASSIVE_SERVICE_HEARTBEAT,            NULL},   /* 心跳 */
    {OPS_PASSIVE_SERVICE_FEE_STRATEGY,         NULL},   /* 计费策略 */
    {OPS_PASSIVE_SERVICE_CARD_AUTH,            NULL},   /* 卡鉴权结果 */
    {OPS_PASSIVE_SERVICE_BILL,                 NULL},   /* 账单 */
};

void *ops_service_callback(int32_t service)
{
    if (service < 0)
    {
        return NULL;
    }

    return g_ops_service_map[service].callback;
}

/* 服务回调函数定义 */
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTIVE_SERVICE_START_CHARGING_APP,    \
        int32_t (*callback)(ops_active_service_start_charging_app_t *request, ops_active_service_feedback_start_charging_app_t *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTIVE_SERVICE_STOP_CHARGING_APP,     \
        int32_t (*callback)(ops_active_service_stop_charging_app_t *request, ops_active_service_feedback_stop_charging_app_t *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTIVE_SERVICE_CARD_SYN,              \
        int32_t (*callback)(ops_active_service_card_syn_t *request, ops_active_service_feedback_card_syn_t *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTIVE_SERVICE_CARD_CLEAR,            \
        int32_t (*callback)(ops_active_service_card_clear_t *request, ops_active_service_feedback_card_clear_t *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTIVE_SERVICE_CARD_QUERY,            \
        int32_t (*callback)(ops_active_service_card_query_t *request, ops_active_service_feedback_card_query_t *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTICE_SERVICE_FEE_STRATEGY,              \
        int32_t (*callback)(ops_passive_service_fee_strategy_t *request, ops_active_service_feedback_fee_strategy_t *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTIVE_SERVICE_TIME_SYN,              \
        int32_t (*callback)(ops_active_service_time_syn_t *request, ops_active_service_feedback_time_syn_t *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTIVE_SERVICE_REBOOT,                \
        int32_t (*callback)(ops_active_service_reboot_t *request, ops_active_service_feedback_reboot_t *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_ACTIVE_SERVICE_START_UPDATE,          \
        int32_t (*callback)(ops_active_service_start_update_t *request, ops_active_service_feedback_start_update_t *feedback));

OPS_DEFINE_SEVICE_CALLBACK(OPS_PASSIVE_SERVICE_SIGN_IN,              \
        int32_t (*callback)(ops_passive_service_sign_in_t *request, void *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_PASSIVE_SERVICE_HEARTBEAT,            \
        int32_t (*callback)(ops_passive_service_heartbeat_t *request, void *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_PASSIVE_SERVICE_FEE_CHECK,         \
        int32_t (*callback)(ops_passive_service_fee_mode_check_t *request, void *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_PASSIVE_SERVICE_FEE_STRATEGY,         \
        int32_t (*callback)(ops_passive_service_fee_strategy_t *request, void *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_PASSIVE_SERVICE_CARD_AUTH,            \
        int32_t (*callback)(ops_passive_service_card_authorize_t *request, void *feedback));
OPS_DEFINE_SEVICE_CALLBACK(OPS_PASSIVE_SERVICE_BILL,                 \
        int32_t (*callback)(ops_passive_service_bill_t *request, void *feedback));
